import http from "@/config/config"
import { ca } from "element-plus/es/locale"

const categoryApi = {
 
    //获取所有分类
    getCategorys:(page:Number,size:Number)=>{
        return http.post(`category/page/${page}/${size}`,{}).then(res=>{
            return res.data
        })
    },
    //添加分类
    addCateGroy:(category:any)=>{
       return http.post('category/add',{
          "name":category.name,
           "type":category.type,
           "typeId":category.type==="菜品分类" ? 1:2 , //如果是菜品分类就是 1， 如果是套餐分类就是2
           "ord":parseInt(category.order)
       }).then(res=>{
         return res.data;
       })
    },
    //修改分类
    updateCateGory:(category:any)=>{
      return http.put('category/update',{
        "id":category.id,
        "name":category.name,
        "type":category.type,
        "typeId":category.type==="菜品分类" ? 1:2 , //如果是菜品分类就是 1， 如果是套餐分类就是2
        "ord":parseInt(category.order)
      }).then(res=>{
        return res.data;
      })
    },
    //批量删除分类
    deleteCates:(ids:[])=>{
        return http.post('category/delete',{
            "ids":ids
        }).then(res=>{
            return res.data;
        })
    },

    //获取菜品分类
    getDishCate:()=>{
      return http.get('/category/dishcate').then(res=>{
        return res.data
      })
    },
    //获取套餐分类
    getTaocanCate:()=>{
        return http.get('/category/taocancate').then(res=>{
            return res.data
        })
    }



}

export default categoryApi;